package com.vcg.vdam.config.redission;

import com.vcg.vdam.aop.ResultResponse;
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName RedissionConfig
 * @Description TODO
 * @Author yangxing02
 * @Date 2020/11/27 17:39
 * @Version 1.0
 */
@Configuration
public class RedissionConfig {

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        //重试次数
        config.useSingleServer().setRetryAttempts(3)
                .setAddress("redis://localhost:6379");
        //默认是30s;(30000);这个可以设置
        config.setLockWatchdogTimeout(5000L);
//        SingleServerConfig singleServerConfig = new SingleServerConfig();


        RedissonClient redisson = Redisson.create(config);

        return redisson;
    }




}
